﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DVK.SP2007.UniversalClient
{
    /// <summary>
    /// DvkFault helps manage fault information that might come with Dvk message when sending or receiving has problems.
    /// </summary>
    public class DvkFault
    {
        public string Code { get; set; }
        public string Actor { get; set; }
        public string Message { get; set; }
        public string Description { get; set; }

        /// <summary>
        /// Constant for value "missing".
        /// </summary>
        public const string MissingValue = "missing";

        /// <summary>
        /// Initializes a new instance of the <see cref="DvkFault"/> class.
        /// </summary>
        /// <param name="code">The code.</param>
        /// <param name="actor">The actor.</param>
        /// <param name="message">The message.</param>
        /// <param name="description">The description.</param>
        public DvkFault(string code, string actor, string message, string description)
        {
            Code = string.IsNullOrEmpty(code) ? MissingValue : code;
            Actor = string.IsNullOrEmpty(actor) ? MissingValue : actor;
            Message = string.IsNullOrEmpty(message) ? MissingValue : message;
            Description = string.IsNullOrEmpty(description) ? MissingValue : description;
        }

        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// <remarks>
        /// Takes all properties and puts them in one string.
        /// </remarks>
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </returns>
        public override string ToString()
        {
            return  "Fault info: " + 
                    "\nCode: " + Code +
                    "\nActor: " + Actor +
                    "\nMessage: " + Message +
                    "\nDescription: " + Description;
        }
    }
}
